<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix='security' uri='http://www.springframework.org/security/tags' %>
<script type="text/javascript">
    var editButtonId = "editLink";
    var editSubmitPath = "edit.html";
    var viewButtonId = "viewLink";
    var viewSubmitPath = "view.html";
    function changeEditTarget(targetKey, targetValue) {
        var submitPath = editSubmitPath + "?" + targetKey + "=" + targetValue + "&" + "lookupType=${lookupType}";
        $("#" + editButtonId).attr("href", submitPath);
    }
    function changeViewTarget(targetKey, targetValue) {
        var submitPath = viewSubmitPath + "?" + targetKey + "=" + targetValue + "&" + "lookupType=${lookupType}";
        $("#" + viewButtonId).attr("href", submitPath);
    }
    function changeTarget(targetKey, targetValue) {
        changeEditTarget(targetKey, targetValue);
        changeViewTarget(targetKey, targetValue);
    }
</script>

<div id="wrapper">
    <!--START: Header -->
    <div class="header">
        <h1><a href="#">logo</a></h1>
    </div>
    <!--END: Header -->
    <!--START: conent -->
    <div class="content">
        <div class="menu">
            <ul>
                <li><a href="#">Questionnaires</a></li>
                <li><a href="<%= request.getContextPath()%>/designer/questionset/list.html">Question Sets</a></li>
                <li><a href="<%= request.getContextPath()%>/designer/question/list.html">Questions</a></li>
                <li class="active"><a href="<%= request.getContextPath()%>/designer/lookup/index.html">Lookup Tables</a></li>
                <li><a href="<%= request.getContextPath()%>/designer/user/list.html">Users</a></li>
                <li><a href="<%= request.getContextPath()%>/designer/group/list.html">Groups</a></li>
            </ul>
        </div>
        <div class="breadcrumb">
            <div class="links"><a href="/dialogs">Admin</a>&gt; <a href="<%=request.getContextPath()%>/designer/lookup/listlookup.html">Lookup Tables</a> &gt; <a href="#">lookups</a> </div>
        </div>
        <div class="insider">
            <div class="column1">
                <dl class="formlayout">
                    <dd>
                        <label for="Keyword">Keyword(s):</label>
                        <input type="text" name="textfield2" id="Keyword" class="input1" />
                    </dd>
                    <dd>
                        <label for="Status">Status:</label>
                        <select name="select3" id="Status" class="select1">
                            <option>ALL</option>
                        </select>
                    </dd>
                    <dd>
                        <label for="Group">Group:</label>
                        <select name="select4" id="Group" class="select1">
                            <option>ALL</option>
                        </select>
                    </dd>
                </dl>
            </div>
            <ul class="functions1">
                <li><a href="#">Search</a></li>
                <security:authorize ifAnyGranted="ROLE_GROUP_ADMIN,ROLE_SYS_ADMIN">
                <li><a href="create.html?lookupType=${lookupType}">Create New </a></li>
                </security:authorize>
            </ul>
            <ul class="functions2">
                <li><a id="viewLink" href="#">View</a></li>
                <security:authorize ifAnyGranted="ROLE_GROUP_ADMIN,ROLE_SYS_ADMIN">
                <li><a id="editLink" href="#">Edit</a></li>
                </security:authorize>
            </ul>
            <div class="scrollbar scorll1">
            <font color="red">
                       <c:out value="${message}"></c:out><br />
                        </font>
                <table width="98%" cellspacing="0" class="table_thead">
                    <thead>
                        <tr>
                            <th width="3%" scope="col">&nbsp;</th>
                            <th width="12%" scope="col"><span class="descending"><a href="#">Code</a></span></th>
                            <th width="13%" scope="col"><a href="#"> Name</a></th>
                            <th width="10%" scope="col"><a href="#">description</a></th>
                            <th width="25%" scope="col" class="ta_c"><a href="#">Group</a></th>
                            <th width="25%" scope="col" class="ta_c"><a href="#">Last Mod</a></th>

                        </tr>
                    </thead>
                </table>
                <div class="table_tbody">
                    <table width="98%" cellspacing="0">
                        <c:if test="${empty lookups}">
                        <font color="red">
                           ${foundMessage}.
                            </font>
                        </c:if>
                        <c:if test="${not empty lookups}">
                            <c:forEach var="datavalidation" items="${lookups}">
                                <tr>
                                    <td width="3%">
                                        <input type="radio" name="radio" id="radio" value="${datavalidation.code}"
                                            onclick="changeTarget('code', '${datavalidation.code}');" />
                                    </td>
                                    <th width="12%">
                                        <a href="#">${datavalidation.code}</a>
                                    </th>
                                    <td width="13%">${datavalidation.name}</td>
                                    <td width="10%">${datavalidation.description}</td>
                                    <td width="25%">${datavalidation.userGroup.name}</td>
                                    <td width="25%">${datavalidation.modifiedOn}</td>
                                </tr>
                            </c:forEach>
                        </c:if>
                    </table>
                </div>
                <!-- Pagination -->
                <%@include file="../../template/pager.jsp" %>
            </div>
        </div>
    </div>
    <!--END: conent -->
    <!--START: Footer -->
    <div class="footer"></div>
    <!--END: Footer -->
</div>
<!--END: Wrapper -->